package com.atguigu.guliedu.edu.handler;

import com.atguigu.common.exception.EduException;
import com.atguigu.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

   @ExceptionHandler(EduException.class)
   public R error(EduException e){
      log.error(e.toString());
      return R.error().message(e.getMessage()).code(e.getCode());
   }
}
